﻿using System;
using System.Collections.Specialized;
using System.Windows.Forms;

namespace HabraReader
{
    public partial class PreferencesForm : Form
    {
        private readonly MainForm MainWindow;
        private StringDictionary  OptionsDictionary;

        public PreferencesForm(MainForm mainform)
        {
            MainWindow = mainform;
            InitializeComponent();
        }

        private void PreferencesFormLoad(object sender, EventArgs e)
        {
            OptionsDictionary             = MainWindow.OptionsDictionary;
            DatabasePathTextedit.Text     = OptionsDictionary["Database"];
            UpdateFolderPathTextedit.Text = OptionsDictionary["UpdateFolder"];
        }

        private void CancelButtonClick(object sender, EventArgs e)
        {
            Close();
        }

        private void OkButtonClick(object sender, EventArgs e)
        {
            OptionsDictionary["Database"]     = DatabasePathTextedit.Text;
            OptionsDictionary["UpdateFolder"] = UpdateFolderPathTextedit.Text;
            MainWindow.OptionsDictionary      = OptionsDictionary;
            Close();
        }
    }
}